package logic

import (
	"context"
	"house/houserpc/houserpc"
	"house/houserpc/internal/svc"
	"house/models/mysql"

	"github.com/zeromicro/go-zero/core/logx"
)

type ConsultShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewConsultShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ConsultShowLogic {
	return &ConsultShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ConsultShowLogic) ConsultShow(in *houserpc.ConsultShowRequest) (*houserpc.ConsultShowResponse, error) {
	// todo: add your logic here and delete this line
	var consult mysql.Consult

	//result, _ := cache.Rdb.Get(l.ctx, in.Problem).Result()
	//if result != "" {
	//	json.Marshal(l.ctx, in.Problem)
	//}
	mysql.DB.Debug().Where("id=?", in.ConsultId).Find(&consult)
	return &houserpc.ConsultShowResponse{
		UserId:  int64(consult.UserId),
		HouseId: int64(consult.HouseId),
		Problem: consult.Problem,
	}, nil
}
